<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<!--<input onkeydown="onlyNum();">-->
<input id="d421" class="Wdate" type="text" onkeydown="onlyNum()" onpaste="return false" />
<button id="btn">按钮</button>
<script language=javascript>
    function onlyNum() {
        var keycode = event.keyCode;
        if (keycode >= 96 && keycode <= 105) {
            keycode = keycode - 48;
        }
        var realkey = String.fromCharCode(keycode);
        if (keycode == 8 || keycode == 46 || (keycode >= 35 && keycode <= 40)){

        }else if (!Number(realkey)){
            event.returnValue = false;
        }
    }

//onkeyup this.value=this.value.replace(/\D/g,"");

</script>
</body>
</html>